<!-- 
 * @Author: guanpf 992093924@qq.com
 * @Date: 2023-07-24 16:46:03
 * @LastEditTime: 2023-10-14 19:07:02
 * @LastEditors: guanpf
 * @Description: 
 * @FilePath: /ZCGL_WX/src/views/main/asset/views/promissoryNote.vue
 -->
<template>
  <div class="promissory-note">
    <div class="top-search">
      <CommonSearch
        placeholder="请输入审批名称、资产名称"
        @searchFun="searchFun"
      ></CommonSearch>
    </div>
    <div class="count">共计{{ count }}条结果</div>
    <div class="list">
      <template v-if="list.length > 0">
        <div
          class="item"
          v-for="(item, index) in list"
          :key="index"
          @click="toDetail(item.orderId)"
        >
          <div class="title">
            <span class="name">借出人：{{ item.userName }}</span>
            <span class="name">借用人：{{ item.borrowUserName }}</span>
            <!-- <span class="time">{{ item.createTime }}</span> -->
          </div>
          <div class="title">
            <span class="status">{{ item.status == 1 ? "已确认" : "未确认" }}</span>
            <span class="time">{{ item.createTime }}</span>
          </div>
        </div>
      </template>
      <template v-else>
        <no-data></no-data>
      </template>
    </div>
  </div>
</template>

<script>
import CommonSearch from "../components/search.vue";
import AssetApi from "@/api/asset.js";
export default {
  components: { CommonSearch },
  data() {
    return {
      name: "",
      count: 0,
      list: [],
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    searchFun(name) {
      this.name = name;
    },
    toDetail(id) {
      this.$router.push({
        path: "promissoryDetail",
        query: {
          orderId: id,
        },
      });
    },
    getList() {
      let _params = {
        // assetName: this.name,
        key: this.name,
        page: 1,
        pageSize: 1000,
        userId: this.$store.state.user.userInfo.wxUserId, //this.$store.state.user.userInfo.userId
      };
      AssetApi.findBorrowAll(_params).then((res) => {
        if (res.code == "0000") {
          this.list = res.data.records;
          this.count = res.data.total;
        }
      });
    },
  },
};
</script>

<style lang="less" scoped>
.promissory-note {
  background: #f1f1f1;
  height: 100vh;
}
.top-search {
  padding: 10px 0;
  background: #fff;
}

.count {
  padding: 10px 20px;
  background: #fff;
}
.list {
  padding: 0 15px;
  background: #f1f1f1;
  .item {
    margin-top: 10px;
    border-radius: 6px;
    padding: 10px 15px;
    background: #fff;
    .title {
      display: flex;
      justify-content: space-between;
      color: #666;
      font-size: 12px;
      height: 40px;
      line-height: 40px;
      .name {
        color: #101010;
        font-size: 14px;
      }
    }
    .status {
      // height: 30px;
      // line-height: 30px;
      font-size: 13px;
      color: rgb(85, 120, 34);
    }
  }
}
</style>
